#include "coordinate_2d.h"
using namespace SeaDrip;

const bool Coordinate2D::operator<(const Coordinate2D& other) const
{
    return (other.y == this->y) ? (other.x > this->x) : (other.y > this->y);
}

Coordinate2D::Coordinate2D(const unsigned int _x, const unsigned int _y) : x(_x), y(_y)
{}

const unsigned int Coordinate2D::GetOffset(const unsigned width)
{
    return y * width + x;
}

const unsigned int Coordinate2D::GetSquareDistanceFromOrigin() const
{
    return x * x + y * y;
}

const bool Coordinate2D::operator == (const Coordinate2D& other) const
{
    return (this->x == other.x) && (this->y == other.y);
}
